Add support for imaginary/virtual/whatever you want to call them partition tables used by raw disks
Change diskno data type back, changing it was a silly idea.
// Convert the partition into a physical extent
Extent e = p.toExtent();
+ int partition_no = p.getMinor() & 0x1F;
- String output = new CommandPhysicalGrant( d, domain_id, e, mode ).execute();
+ String output = new CommandPhysicalGrant( d, domain_id, e, mode, partition_no ).execute();
if ( output != null )
System.out.println( output );
}
private int domain_id;
private Extent extent;
private Mode mode;
+ private int partition_no;
/**
* Constructor for CommandPhysicalGrant.
* @param domain_id Domain to grant access for.
* @param extent Extent to grant access to.
* @param mode Access mode to grant.
+ * @param partition_no Partition number to use (or zero for none).
*/
public CommandPhysicalGrant(
Defaults d,
int domain_id,
Extent extent,
- Mode mode) {
+ Mode mode,
+ int partition_no) {
this.d = d;
this.domain_id = domain_id;
this.extent = extent;
this.mode = mode;
+ this.partition_no = partition_no;
}
public String execute() throws CommandFailedException {
try {
Process start_p;
- String start_cmdarray[] = new String[6];
+ String start_cmdarray[] = new String[7];
int start_rc;
start_cmdarray[0] = d.XIToolsDir + "xi_phys_grant";
if ( mode == Mode.READ_WRITE )
else
throw new CommandFailedException( "Unknown access mode '" + mode + "'" );
start_cmdarray[2] = Integer.toString( domain_id );
- start_cmdarray[3] = Short.toString( extent.getDisk() );
+ start_cmdarray[3] = Integer.toString( extent.getDisk() );
start_cmdarray[4] = Long.toString( extent.getOffset() );
start_cmdarray[5] = Long.toString( extent.getSize() );
+ start_cmdarray[6] = Integer.toString( partition_no );
if (Settings.TEST) {
output = reportCommand(start_cmdarray);
int start_rc;
start_cmdarray[0] = d.XIToolsDir + "xi_phys_revoke";
start_cmdarray[1] = Integer.toString( domain_id );
- start_cmdarray[2] = Short.toString( extent.getDisk() );
+ start_cmdarray[2] = Integer.toString( extent.getDisk() );
start_cmdarray[3] = Long.toString( extent.getOffset() );
start_cmdarray[4] = Long.toString( extent.getSize() );
public class
Extent
{
- short disk;
+ int disk;
long offset; /* offset into disk */
long size; /* size of this extent in 512 byte sectors */
- public short
+ public int
getDisk()
{
return disk;
{
Extent e = new Extent();
// Build 16-bit disk number.. high 8 bits are the major
- int disknum = major << 8;
+ e.disk = major << 8;
// Low 8 bits are the minor, but bottom 5 need to be cleared
// as they are the partition number, not the disk number
- disknum |= ( minor & 0xE0 );
- e.disk = (short) disknum;
+ e.disk |= ( minor & 0xE0 );
e.offset = start_sect;
e.size = nr_sects;
return e;
{
if ( e.getMajor() != major )
return false;
- if ( e.getMinor() != (minor & 0xE0) )
+ if ( e.getMinor() != minor )
return false;
if ( e.offset != start_sect )
return false;